<?php

namespace app\admin\controller;

use app\admin\model\Store;

use think\Request;

class Storetradedetail extends Base
{

    public function getlist(){
        $params = $this->request->param();
        $where = [];
        if(isset($params['orderNO']) && $params['orderNO']){
            $where['orderNO'] = ['like', "%{$params['orderNO']}%"];
        }

        $model = model('Storetradedetail');
        $list = $model->where($where)->order('payTime DESC')->paginate(10);
        $total = $model->where($where)->count();

        if($list){
            foreach ($list as &$item) {
                $item['storeName'] = Store::where('id', $item['payStoreId'])->value('name');
                $item['payMoney'] = money_format("%.2n",$item['payMoney']/100);
                switch ($item['payType']) {
                    case 0:
                        $item['payType'] = '微信'; break;
                    case 1:
                        $item['payType'] = '支付宝'; break;
                    case 2:
                        $item['payType'] = '银联'; break;
                    case 3:
                        $item['payType'] = '账户余额'; break;
                    default: break;
                }
            }
        }

        return $this->fetch('',[
            'datas' => $list,
            'total' => $total,
            'formget' => $_GET
        ]);
    }


}